package cn.wolfcode.service.impl;

import cn.wolfcode.domain.SystemDictionaryItem;
import cn.wolfcode.mapper.SystemDictionaryItemMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.ISystemDictionaryItemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemDictionaryItemServiceImpl implements ISystemDictionaryItemService {

    @Autowired
    private SystemDictionaryItemMapper systemDictionaryItemMapper;

    @Override
    public int insertSystemDictionaryItem(SystemDictionaryItem record) {
        systemDictionaryItemMapper.insert(record);
        return 0;
    }

    @Override
    public int deleteSystemDictionaryItem(Long id) {
        systemDictionaryItemMapper.deleteByPrimaryKey(id);
        return 0;
    }

    @Override
    public int updateSystemDictionaryItem(SystemDictionaryItem record) {
        return systemDictionaryItemMapper.updateByPrimaryKey(record);
    }

    @Override
    public SystemDictionaryItem selectSystemDictionaryItem(Long id) {
        return systemDictionaryItemMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SystemDictionaryItem> selectSystemDictionaryItemList() {
        return systemDictionaryItemMapper.selectAll();
    }


    @Override
    public PageInfo<SystemDictionaryItem> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        return new PageInfo<SystemDictionaryItem>(systemDictionaryItemMapper.queryList(qo));
    }

    @Override
    public List<SystemDictionaryItem> selectByTypeId(Long id) {
        return systemDictionaryItemMapper.selectByTypeId(id);
    }

    @Override
    public List<SystemDictionaryItem> selectByTypeSn(String sn) {
        return systemDictionaryItemMapper.selectByTypeSn(sn);
    }

    @Override
    public List<SystemDictionaryItem> selectByParentId(Long id) {
        return systemDictionaryItemMapper.selectByParentId(id);
    }

}
